#ifndef __DEBUG_H_
#define __DEBUG_H_

#include <time.h>
#include <sys/time.h>

//#define _DEBUG_SEARCH_

#ifdef _DEBUG_SEARCH_

#include <cutils/log.h>
/*
static uint64 _ellapse_search_ = 0;
static struct timeval _tv_start_search_search_search_, _tv_end_search_search_;
#define DEBUG_SEARCH_BEGIN \
    do { \
      gettimeofday(&_tv_start_search_, NULL); \
    } while(0)
#define DEBUG_SEARCH_END \
    do { \
      gettimeofday(&_tv_end_search_, NULL); \
      _ellapse_ = (_tv_end_search_.tv_sec - _tv_start_search_.tv_sec) * 1000000 + \
                  (_tv_end_search_.tv_usec - _tv_start_search_.tv_usec); \
    } while(0)
#define LOGD_SEARCH(message) \
    LOGD("Marix Search engine info : [%s]. using %llu usec.", message, _ellapse_search_);
*/
static struct timeval _tv_time_;
static struct time_t _time_;
#define LOGD_SEARCH(message)
	do{ \
		time( &_time_ ); \
		gettimeofday( &_tv_time_ ); \
		LOGD( "Matrix search engine log : [%s]. time : %s, %d \n", message, ctime(&_time_), _tv_time_.tv_usec ); \

	}while(0)
#else
//#define DEBUG_SEARCH_BEGIN
//#define DEBUG_SEARCH_END
#define LOGD_SEARCH(message)

#endif

void print_cur_time()
{
#ifdef _ONLY_ENGINE_DEBUG_
	static char log_buf[500];
	memset( log_buf, 0, 500 );
	time_t timer;
	time( &timer );
	sprintf( log_buf, "Current time : %s ", ctime(&timer) );
	int length = strlen( log_buf );

	timeval time_d;
	int ret = gettimeofday( &time_d, NULL );
	if( 0==ret )
	{
		sprintf( &log_buf[length-2], "   Detail time : %ld usec. \n", time_d.tv_usec );
		printf("%s", log_buf );
	}
#endif

#ifdef _DEBUG_SEARCH_
	//out the log in emulator
	LOGD_SEARCH("emulator");
#endif
}

#endif
